<template>
	<view>

		<uni-swiper-dot :info="list" mode="round"
			:dots-styles="{backgroundColor:'rgba(0,0,0,0.5)',selectedBackgroundColor:'#ffffff',selectedBorder:'#fff'}"
			:current="current">
			<swiper class="swiperCpmtaomer" autoplay @change="changeBanner">
				<swiper-item v-for="item in shop.goodimgList" :key="item">
					<image class="img" :src="item"></image>
				</swiper-item>
			</swiper>
		</uni-swiper-dot>

		<view style="text-align: center; font-size: 22px;">
			{{shop.goodName}}
		</view>
		<view style="display: flex;">
			<view class="sp22">
				￥{{shop.goodPrice*1.1}}
			</view>
			<view class="sp2">
				￥{{shop.goodPrice}}
			</view>
		</view>
		<view class="sp3">
			<view style="width: 20%; margin-left: 4%;">
				销售量:{{shop.goodSold}}
			</view>
			<view style="width: 30%;">
				收藏量:{{shop.goodCollect}}
			</view>
			<view style="width: 30%;">
				浏览量:{{shop.goodLook}}
			</view>
		</view>
		<view class="sp4">
			<view class="sp4-1">购买类型<view class="sp4-2">{{shop.goodquaList[1].val}}</view>
			</view>
			<view class="sp4-1">促销活动<view class="sp4-2">
					<view v-for="item in shop.goodpromotion">
						{{item.name}}
					</view>
				</view>
			</view>
			<view class="sp4-1">服务<view class="sp4-3">
					<view v-for="item in shop.goodservice">{{item.name}}</view>
				</view>
			</view>

		</view>
		<view class="sp5" @click="bbb(1)">
			<view class="sp5-1">评价({{shop.goodCommectDetail.length}})</view>
			<view>好评率&nbsp;100%</view>
		</view>
		<view class="sp5-2" v-for="item in shop.goodCommectDetail" v-show="judge">
			<view class="sp5-3">
				<view class="sp5-3-1">
					<image :src="item.userface"></image>
				</view>
				<view class="sp5-4">{{item.username}}
					<view>
						{{item.content}}
					</view>
					<view class="sp5-5">
						<view v-for="items in item.imgList" style="margin-left: 1%;">
							<image :src="items"></image>
						</view>
					</view>
				</view>
			</view>

		</view>


		<view class="sp6">
			<view class="sp6-1">图文详情</view>

			<view v-for="item in shop.goodimgList" class="sp6-2">
				<image :src="item"></image>
			</view>

		</view>
		<view class="sp7">
			<view class="sp7-1">
				<uni-icons type="headphones" size="30"></uni-icons>
				<view>客服</view>
			</view>
			<view class="sp7-1">
				<uni-icons type="shop" size="30"></uni-icons>
				<view>店铺</view>
			</view>
			<view class="sp7-1">
				<uni-icons type="cart" size="30"></uni-icons>
				<view>购物车</view>
			</view>
			<button class="bt-1" @click="now">加入购物车</button>
			<button class="bt-2" @click="now">立即购买</button>
		</view>
		<uni-popup ref="popup" type="bottom">
			<view class="sp-8">
				<view class="sp8-1">
					<view class="sp8-2">
						<image :src="shop.goodImg"></image>
					</view>
					<view class="sp8-3">
						￥{{shop.goodPrice}}
						<view style="display: flex; width: 100%;">
							<view style="color: #939393; width: 20%;">已选</view>
							<view style="color: black;padding-left: 1%; width: 70%;">{{shop.goodquaList[1].val}}</view>

						</view>
					</view>

				</view>
				<view>
					<view class="sp8-4">类型</view>
					<scroll-view :scroll-top="scrollTop" scroll-y="true" style="height: 80px;">
						<view class="sp8-5">
							<view v-for="(item,index) in shop.goodquaList" class="sp8-5-1">
								{{item.val}}
							</view>
						</view>
					</scroll-view>
					<view class="sp8-7">
						<view class="sp8-6">数量</view>
						<view><u-number-box></u-number-box></view>
					</view>
				</view>
				<view class="sp8-8">
					<button>确认</button>
				</view>
			</view>
		</uni-popup>
	</view>



</template>

<script>
	import {
		apiGoods,
	} from '../../api/mock'
	export default {
		data() {
			return {
				shop: {},
				judge: false,
				num: 0,
				current: 0,
				scrollTop: 0

			}
		},
		methods: {
			changeBanner(e) {
				this.current = e.detail.current;
			},
			now() {
				this.$refs.popup.open('bottom');
			},
			bbb(e) {
				this.num = this.num + e;
				console.log(e);
				console.log(this.num);
				if (this.num % 2 == 0) {
					this.judge = false;
				} else {
					this.judge = true;
				}
			}
		},
		onLoad(e) {
			console.log('拿到下标');
			console.log(e.index);
			uni.showLoading({
				title: '加载中...',
				mask: true,
			});
			setTimeout(() => {
				apiGoods(1, 28, '全部').then((res) => {
					console.log('是否拿到数据');
					console.log(res);
					this.shop = res[e.index]
					console.log('是否拿到数据');
					console.log(this.shop);
					console.log(this.shop.goodimgList);
				}).catch((err) => {
					console.log(err);
				});


				uni.hideLoading();
			}, 1000)

		},

	}
</script>

<style>
	.swiperCpmtaomer {
		width: 100%;

	}

	.swiperCpmtaomer image {
		width: 100%;
		height: 100%;
	}

	.sp22 {
		color: #939393;
		width: 25%;
		margin-top: 2%;
		text-align: center;
		text-decoration: line-through;

	}

	.sp2 {
		color: red;
		width: 10%;
		margin-top: 2%;

	}

	.sp3 {
		width: 100%;
		margin-top: 2%;
		color: #939393;
		display: flex;
		text-align: center;
	}

	.sp4 {
		margin-top: 5%;
		width: 100%;
		/* display: flex; */

	}

	.sp4-1 {
		margin-left: 4%;
		width: 100%;
		color: #939393;
		display: flex;
		margin-top: 5%;
	}

	.sp4-2 {
		width: 70%;
		color: black;
		margin-left: 10%;
	}

	.sp4-3 {
		width: 70%;
		color: black;
		margin-left: 17%;
		display: flex;
	}

	.sp5 {
		width: 92%;
		margin: 0 auto;
		margin-top: 5%;
		display: flex;
		/* 两边对齐 */
		justify-content: space-between;
	}

	.sp5-1 {
		font-weight: bold;

	}

	.sp5-2 {
		width: 90%;
		margin: 0 auto;
		margin-top: 3%;
	}

	.sp5-3 {
		display: flex;
	}

	.sp5-3-1 image {
		width: 50px;
		height: 50px;
		border-radius: 50%;
	}

	.sp5-4 {
		margin-left: 5%;
	}

	.sp5-5 {
		display: flex;
	}

	.sp5-5 image {
		width: 90px;
		height: 90px;
	}

	.sp6 {
		margin-top: 10%;
		text-align: center;
		font-size: 20px;
	}

	.sp6-1 {
		margin-bottom: 5%;
	}

	.sp6-2 {
		width: 100%;
	}

	.sp6 image {
		width: 100%;
	}

	.sp7 {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 80px;
		/* 高度根据实际需要调整 */
		background-color: #ffffff;
		display: flex;
	}

	.sp7-1 {
		margin-left: 5%;
	}

	.sp7 button {
		height: 50px;
		margin-top: 2%;
		border-radius: 20px;
		color: white;
	}

	.sp7 button.bt-1 {
		background-color: #ef532c;
	}

	.sp7 button.bt-2 {
		background-color: #ff7900;
	}

	.sp-8 {
		width: 100%;
		height: 450px;
		border-radius: 12px;
		background-color: white;

	}

	.sp8-1 {
		margin: 0 auto;
		display: flex;
		width: 95%;


	}

	.sp8-2 {
		width: 40%;
		height: 150px;
		margin-top: 5%;
		border: 1px solid #636363
	}

	.sp8-2 image {
		width: 100%;
		height: 100%;
	}

	.sp8-3 {
		width: 60%;
		color: red;
		padding-top: 25%;
	padding-left: 2%;
	}

	.sp8-4 {
		font-weight: bold;
		font-size: 25px;
		margin-left: 4%;
		margin-top: 3%;
	}

	.sp8-5 {
		width: 90%;
		height: 100px;
		margin: 0 auto;
		display: flex;
		flex-wrap: wrap;
		/* border: 1px solid black; */

	}

	.sp8-5-1 {
		margin-top: 2%;
		background-color: #f2f2f2;
		margin-left: 3%;
		margin-top: 3%;
		color: #c8c8c8;
		height: 30px;
		border-radius: 20px;
		padding: 6px;

	}

	.sp8-6 {
		font-weight: bold;
		font-size: 25px;

	}

	.sp8-7 {
		width: 90%;
		display: flex;
		justify-content: space-between;
		margin: 0 auto;
		margin-top: 3%;
	}

	.sp8-8 {
		width: 90%;
		height: 60px;
		margin: 0 auto;
		margin-top: 3%;

	}

	.sp8-8 button {
		width: 100%;

		border-radius: 20px;
		background-color: red;
		color: white;

	}
</style>